package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppEmployee;
import com.ep.modules.app.service.AppEmployeeService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/employee")
public class AppEmployeeController {
    @Autowired
    private AppEmployeeService appEmployeeService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appEmployeeService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppEmployee appemployee = appEmployeeService.getById(id);
        return R.ok().put("appemployee", appemployee);
    }

    @SysLog("保存AppEmployee")
    @PostMapping("/save")
    public R save(@RequestBody AppEmployee appemployee) {
        ValidatorUtils.validateEntity(appemployee);
        appEmployeeService.save(appemployee);
        return R.ok();
    }

    @SysLog("修改AppEmployee")
    @PostMapping("/update")
    public R update(@RequestBody AppEmployee appemployee) {
        ValidatorUtils.validateEntity(appemployee);
        appEmployeeService.update(appemployee);
        return R.ok();
    }

    @SysLog("删除AppEmployee")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appEmployeeService.deleteBatch(ids);
        return R.ok();
    }
}